<template>
	<view class="body">
		<view class="news-title-box">
			<view class="news-title">
				{{newsInfo.newsTitle}}
			</view>
			<view class="news-time">
				{{newsInfo.newsPublishTime}}
			</view>
			<view class="content-box" >
				<view class="item-for" v-for="(item, i) in newsInfo.dataList" :key="i">
					<view class="text" v-if="newsInfo.typeList[i] === 'T'">{{item}}</view>
					<view class="img" v-else>
						<image :src="item" mode=""></image>
					</view>
				</view>
			</view>
			
			<!-- <view class="content-box" v-if="newsInfo.index === '1'">
				<view class="text">{{newsInfo.content.text.p1}}</view>
				<view class="img">
					<image :src="newsInfo.content.imgList.img1" mode=""></image>
				</view>
				<view class="text">{{newsInfo.content.text.p2}}</view>
				<view class="text">{{newsInfo.content.text.p3}}</view>
				<view class="img">
					<image :src="newsInfo.content.imgList.img2" mode=""></image>
				</view>
				<view class="text">{{newsInfo.content.text.p4}}</view>
				<view class="text">{{newsInfo.content.text.p5}}</view>
				<view class="img">
					<image :src="newsInfo.content.imgList.img3" mode=""></image>
					<image :src="newsInfo.content.imgList.img4" mode=""></image>
				</view>
				<view class="text">{{newsInfo.content.text.p6}}</view>
				<view class="img">
					<image :src="newsInfo.content.imgList.img5" mode=""></image>
				</view>
				<view class="text">{{newsInfo.content.text.p7}}</view>
				<view class="img">
					<image :src="newsInfo.content.imgList.img6" mode=""></image>
				</view>
				<view class="text">{{newsInfo.content.text.p8}}</view>
			</view>
		
			<view class="content-box" v-if="newsInfo.index === '2'">
				
				<view class="img">
					<image :src="newsInfo.content.imgList.img1" mode=""></image>
				</view>
				<view class="text">{{newsInfo.content.text.p1}}</view>
				<view class="img">
					<image :src="newsInfo.content.imgList.img2" mode=""></image>
				</view>
				<view class="text">{{newsInfo.content.text.p2}}</view>
				<view class="img">
					<image :src="newsInfo.content.imgList.img3" mode=""></image>
					<image :src="newsInfo.content.imgList.img4" mode=""></image>
					<image :src="newsInfo.content.imgList.img5" mode=""></image>
				</view>
				<view class="text">{{newsInfo.content.text.p3}}</view>
				<view class="img">
					<image :src="newsInfo.content.imgList.img6" mode=""></image>
					<image :src="newsInfo.content.imgList.img7" mode=""></image>
				</view>
				<view class="text">{{newsInfo.content.text.p4}}</view>
				<view class="img">
					<image :src="newsInfo.content.imgList.img8" mode=""></image>
					<image :src="newsInfo.content.imgList.img9" mode=""></image>
					<image :src="newsInfo.content.imgList.img10" mode=""></image>
				</view>
				<view class="text">{{newsInfo.content.text.p5}}</view>
				<view class="img">
					<image :src="newsInfo.content.imgList.img11" mode=""></image>
				</view>
				<view class="text">{{newsInfo.content.text.p6}}</view>
			</view>
					
			<view class="content-box" v-if="newsInfo.index === '3'">
				<view class="img">
					<image :src="newsInfo.content.imgList.img1" mode=""></image>
				</view>
				<view class="text-box">
					<view class="text">{{newsInfo.content.text.p1}}</view>
					<view class="text">{{newsInfo.content.text.p2}}</view>
				</view>
			</view> -->
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				newsInfo: {
					dataList: [],
					newsPublishTime: '',
					newsTitle: '',
					typeList: []
				}
			};
		},
		methods: {
			async setNewsInfo(newsNo) {
				// 显示加载界面
				// wx.showLoading({  // 显示加载中loading效果 
				//     title: "加载中",
				//     mask: true  //开启蒙版遮罩
				//   });
				// console.log("newsInfo: ", JSON.parse(newsInfo))
				const {data: res} = await uni.$http.get('/news/info/'+newsNo)
				// console.log('新闻视图类：', res)
				if(res.msg !== 'success') return uni.$showMsg('查询新闻数据失败')
				this.newsInfo = res.news
				 //关闭加载中
				// uni.hideLoading();
				// setTimeout(function () {
				// 	console.log('加载关闭')
				// 	uni.hideLoading();
				// }, 10000);
			}
		},
		onLoad(options) {
			//显示加载界面
			// uni.showLoading({
			// 	title: "加载中",
			// 	mask: true  //开启蒙版遮罩
			// })
			//显示加载界面
			// uni.showToast({  // 显示加载中loading效果2秒
			//   title: '加载中!!!',
			//   icon: 'loading',
			//   duration: 3000    //提示的延迟时间
			// });
			this.setNewsInfo(options.newsNo)
			// uni.hideLoading();
			
		}
	}
</script>

<style lang="scss">
.body {
	.news-title-box {
		.news-title {
			text-align: center;
			font-size: 20px;
			font-weight: bold;
		}
		.news-time {
			text-align: end;
			margin: 10px;
			color: #5e5e5e;
		}
		.content-box {
			.text {
				margin: 10px;
				font-size: 18px;
				display: flex;
				justify-content: center;
			}
			.img {
				display: flex;
				flex-wrap: wrap;
				justify-content: center;
				image {
					margin: 10px 0;
				}
			}
			
			//第三则资讯
			.text-box {
				display: flex;
				justify-content: center;
				align-items: center;
				flex-direction: column;
				font-size: 18px;
				color: #5e5e5e;
			}
		}
	}
}
</style>
